<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script type="text/javascript">
    let number = 18
    let person = {
      name: 'zhangsan'
    }
    Object.defineProperty(person, 'age', {
      // value: 18
      // writable: true, // 可写
      // enumerable: true, // 可枚举
      // configurable: true // 可配置-可删除
      // writable: false, // 不可写
      // 
      get() {
        return number
      },
      // 设置值
      set(value) {
        number = value
      }
    })
    // 不可枚举
    console.log(person)
  </script>
</body>

</html>